home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln1086.arc
/
BEEFUP.LTG
< prev
next >
Wrap
Text File
|
1986-09-15
|
9KB
|
302 lines
Listings 1-7 for Beefing Up BASIC with Assembly
page 60,132
comment @
This is a single-line function which tests the specified bit in the given
string. The function returns -1 if the bit is set, else 0.
DEFINT A-Z
DEF FNTB(A1$,A1) = (ASC(MID$(A1$,INT(A1/8)+1)) AND (2^(A1-INT(A1/8)*8))) <> 0
where A1$ is the bit map and A1% is the position to be tested.
@
code segment byte public 'code'
assume cs:code
comment *
TESTBIT
written for DCD Company 11/7/85 by Bill Borg
This routine will test the bit at a given position (0-2039) in a string.
It is to be called by a program written for the IBM BASIC Compiler 2.0
Three parameters are passed:
1) The string to be tested (up to 255 characters)
2) The position in the string to be checked (0-2039)
3) An integer to return -1 if the bit is set, else 0
*
testbit proc far
public testbit ; define the entry point
push bp ; establish addressability of the stack
mov bp,sp
mov bx,[bp+10]
mov si,[bx+2] ; SI now points to the bit map to be tested
; compiler uses a 4-byte string descriptor
mov bx,[bp+8]
mov ax,[bx] ; AX contains the position to be tested
mov bl,8
div bl ; divide the position by 8 to get the byte
mov bh,ah ; save the remainder
xor ah,ah ; clear the remainder from AH
add si,ax ; SI now points to appropriate byte in the map
mov bl,byte ptr [si] ; get the byte into BL
mov cl,bh ; get the desired position within the byte
xor ax,ax ; AX will return the result
ror bl,cl ; roll the desired bit into first position
and bl,1 ; test the bit
jz exit ; the bit was not set, leave 0 in AX
dec ax ; the bit was set, return -1
exit:è mov bx,[bp+6] ; get the address of the return integer
mov [bx],ax ; return 0 or -1
pop bp ; restore the base pointer
ret 6 ; clean up our stack
testbit endp
comment *
SCRSAVE
written for DCD Company 3/10/86 by Bill Borg
This is a routine that will save or restore an entire screen.
It waits until after a horizontal retrace to avoid a flash.
The check for mono/color is done within this routine.
Two parameters are passed:
1) The string variable which holds or will hold the screen
This string must be exactly 4000 bytes long. This routine,
as written here, may thus not be called by the Interpreter.
2) The function ( 0 to save, NOT 0 to restore)
*
scrsave proc far
public scrsave ; define entry point of the routine
push bp ; establish addressability of the stack
mov bp,sp
push ds ; save data segment for return
push es ; save extra segment for return
scr_check: ; check for color or mono
mov ah,15 ; function to get current video state
int 10h ; video bios call
; assume monochrome
mov cx,0b000h ; address of screen buffer for mono
mov dx,03bah ; address of 6845 chip for mono
cmp al,7 ; is it mono?
jz opt_check ; it sure is!
mov cx,0b800h ; no - it must be color
mov dx,03dah ; address of 6845 chip for CGA
opt_check:
mov bx,[bp+6] ; get option
mov ax,[bx] ; AX holds the option word
mov bx,[bp+8] ; get address of string descriptor
cmp al,0 ; are you saving or restoring?
jne put_scr ;
get_scr: ; routine to save the screen
mov si,0 ; offset 0 into the screen
mov di,[bx+2] ; offset of the string
mov ds,cx ; put screen segment as the source
jmp do_it ; go do the move
put_scr: ; routine to restore the screen from a string
mov si,[bx+2] ; offset of the string is the source
mov di,0 ; offset 0 into the screen
mov es,cx ; put screen segment as the destination
do_it: ; perform the moveè mov cx,2000 ; move 2000 words
p1: ; wait for horizontal retrace
in al,dx ; get status
test al,1 ; is it low?
jnz p1 ; wait until it is
cli ; disable interrupts
p2:
in al,dx ; get status
test al,1 ; is it high?
jz p2 ; wait until it is
move:
movsw ; do the move
sti ; enable interrupts
loop p1 ; go until all 2000 words have been moved
finish:
pop es
pop ds
pop bp
ret 4 ; restore the four bytes on the stack
;
scrsave endp
comment *
GETVER
written for DCD Company 6/12/85 by Bill Borg
This routine will return the major and minor version numbers of DOS.
One parameter is passed:
1) An integer to return the major version number (2,3,etc.) in the
low byte and the minor version number (0,10,20,etc.) in the high
byte.
*
getver proc far ; all calls from BASIC are far calls
public getver ; declare entry point for external call
push bp ; establish addressability of stack
mov bp,sp
mov ah,30h ; function to get DOS Version Number
int 21h ; make the DOS call
; AX returns with the minor/major versions
mov bx,[bp+6] ; get the address of the return integer
mov [bx],ax ; move minor/major back to BASIC data segment
pop bp ; restore BASIC's base pointer
ret 2 ; restore the two bytes that we passed
getver endp
comment *
è DATESET
This routine will take the specified file and set its time to 12:00p
and its date to whatever is passed.
Three parameters are passed:
1) The date in three-byte YMD format where:
Y = 80-199 (80 = 1980) M = 1-12 D = 1-31
2) ASCIIZ string representing the path/name of the file to be stamped
3) An integer to return 0 for a successful operation, or -1 if an error
occurred on the open, the set, or the close.
*
dateset proc far
public dateset ; declare entry point for external call
push bp ; establish addressability of stack
mov bp,sp
open_file:
mov bx,[bp+8] ; get the pointer to the file name
mov dx,[bx+2] ; DX points to the filename
sub al,al ; clear AL to open for read
mov ah,3Dh ; function to open a file
int 21h ; call DOS
jc no_dice ; carry flag is set on an error
push ax ; save the file handle
set_date:
mov bx,[bp+10] ; get the pointer to the date
mov si,[bx+2] ; SI will point to the three-byte date
year:
mov al,[si] ; get the year
sub al,80 ; put the year into DOS terms (0-119)
xor dx,dx ; clear DX
mov dh,al ; DX will end up holding the whole date
; DX is "xyyyyyyy/xxxxxxxx"
month:
mov dl,[si+1] ; get the month
; DX is xyyyyyyy/xxxxmmmm
mov cl,4
shl dl,cl ; shift the month into the four high bits
; DX is xyyyyyyy/mmmmxxxx
rol dx,1 ; roll DX into the form "yyyyyyym/mmmxxxxx"
day:
mov al,[si+2] ; get the day
or dl,al ; mov the day into DX
; DX is "yyyyyyym/mmmddddd"
set_time:
mov cx,0110000000000000b; set the time to 12:00:00p
; time is hhhh/mmmmmm/xxxxx
do_set:
mov ah,57h ; function to get/set the time
mov al,1 ; code to set the time (rather than get)
pop bx ; retrieve the file handle that we pushed
int 21h ; call DOS
jc no_dice ; carry flag is set on errorèclose_file:
mov ah,3Eh ; function to close a file
int 21h ; call DOS
jc no_dice ; carry flag is set on error
sub ax,ax ; return an error code of 0
jmp get_out
no_dice: ; we hit an error somewhere
mov ax,-1 ; return error code of -1
get_out:
mov bx,[bp+6]
mov [bx],ax ; return an error code of 0 or -1
pop bp
ret 6 ; restore the stack
dateset endp
comment *
PRTSC
written for DCD Company 9/3/85 by Bill Borg
This routine forces a print screen.
No parameters are passed.
*
prtsc proc far
public prtsc ; establish entry point for the call
push bp ; establish addressability of the stack
mov bp,sp
int 5h ; interrupt five to do the print screen
pop bp ; restore BASIC's base pointer
ret ; return
prtsc endp
comment *
MEMSIZE
written for DCD Company 1/7/86 by Bill Borg
This routine returns the number of contiguous 1K blocks of memory
in the system.
An integer is passed to return the number.
*
memsize proc far
public memsize ; establish entry point for the call
push bp ; establish addressability of the stack
mov bp,sp
int 12h ; make the memory_size_determine call
mov bx,[bp+6] ; get the address of the return integer
mov [bx],ax ; AX has the number of 1K blocks
pop bp ; restore BASIC's base pointer
ret 2 ; restore the stack and return
memsize endp
ècomment *
VIDEO
written for DCD Company 2/7/86 by Bill Borg
This is a generic routine that makes an INT 10H call.
Four parameters are passed corresponding to CX,DX,AX,BX.
All parameters must be passed, although not all need be defined.
*
video proc far
public video ; establish the entry point for the call
push bp ;establish addressability of the stack
mov bp,sp
mov bx,[bp+12] ; CX
mov cx,[bx]
mov bx,[bp+10] ; DX
mov dx,[bx]
mov bx,[bp+8] ; AX
mov ax,[bx]
mov bx,[bp+6] ; BX
mov bx,[bx]
int 10h
pop bp
ret 8 ;restore the eight bytes on the stack
video endp
code ends
end